<template>
  <div>
    <el-form ref="form" :model="formData" label-width="80px">
  <el-form-item label="文章标题">
    <el-input v-model="formData.title"></el-input>
  </el-form-item>
<el-form-item label="文章内容">
    <el-input :autosize="{minRows:5,maxRows:10}" type="textarea" v-model="formData.content"></el-input>
  </el-form-item>
  <el-form-item label="内容分布">
    <el-select v-model="formData.tip" placeholder="请选择区域">
      <el-option label="js" value="js"></el-option>
      <el-option label="node" value="node"></el-option>
      <el-option label="java" value="java"></el-option>
      <el-option label="c++" value="c++"></el-option>
      <el-option label="python" value="python"></el-option>
     
    </el-select>
  </el-form-item>
  <el-form-item label="文章作者">
    <el-input v-model="formData.author"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" :plain="true"  @click="onSubmit">立即发布</el-button>
    <el-button @click="Cancel">取消</el-button>
  </el-form-item>
   </el-form>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
  return {
    detailData:{},
    id:this.$route.params.data.id,
    formData:{
      title:this.$route.params.data.title,
    content:this.$route.params.data.content,
    tip:this.$route.params.data.tip,
    author:this.$route.params.data.author,
    }
  }
},

methods:{
    onSubmit(){
        // console.log(this.id);
        axios.post('/updatePoke',{
     title:this.formData.title,
    content:this.formData.content,
    tip:this.formData.tip,
    author:this.formData.author,
    id:this.id
  }).then(res=>{
    console.log(res);
    this.$message('修改成功！');
  }).catch(error=>{
    console.log(error);
  })
  this.$router.replace({
        path:'/block',
        name:'block'
      })

    
    },
    Cancel(){
        this.formData.title='',
    this.formData.content='',
   this.formData.tip='',
  this.formData.author=''
    }
}
}
</script>

<style>

</style>